//
//  ViewController.m
//  11104
//
//  Created by student on 16/2/29.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIScrollView *scrollview;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.scrollview.backgroundColor = [UIColor blackColor];
    self.scrollview.contentSize = CGSizeMake(480, 60);
    for (int i = 0; i < 6; i++)
    {
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(i*80, 0, 80, 60)];
//    button1.backgroundColor = [UIColor redColor];
    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor greenColor] forState:UIControlStateHighlighted];
    [button setTitle:[NSString stringWithFormat:@"新闻%d",i] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(btnpressed) forControlEvents:UIControlEventTouchUpInside];
    [self.scrollview addSubview:button];
    }
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)btnpressed
{
    NSLog(@"按钮");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
